from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class Base():
    def __init__(self):
        cap={
              "platformName": "Android",
              "appium:deviceName": "emulator-5554",
              "appium:automationName": "uiautomator2",
              "appium:appPackage": "com.xiachufang",
              "appium:appActivity": ".activity.home.HomeActivity",
              "appium:noReset": True
            }
        self.driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',cap)
        self.driver.implicitly_wait(10)

    def find_element(self,loc):
        ele=self.driver.find_element(*loc)
        return ele
    def find_ele_wait(self,loc):
        ele=WebDriverWait(self.driver,20).until(EC.element_to_be_clickable(loc))
    def hua(self,x,y,x1,y1):
        self.driver.swipe(x,y,x1,y1)
    def dian(self):
        self.driver.tap()